//
//  XPhotoModel.h
//  XPhotoLibraryKit
//
//  Created by Wu,Xinting on 2018/3/20.
//

#import <Foundation/Foundation.h>

@import Photos;
@class XPhotoModel, XPhoto;
@protocol XPhotoModelDelegate

@optional
@required
- (void)photoModel:(XPhotoModel *)photoModel loadFinished:(PHFetchResult<PHAsset *> *)photos;

@end

@interface XPhotoModel : NSObject

@property (nonatomic, weak) id<XPhotoModelDelegate> delegate;
@property (nonatomic, readonly) PHFetchResult<PHAssetCollection *> *colls;
@property (nonatomic, readonly) NSUInteger totalCount;

- (NSArray<XPhoto *> *)assetsInColl:(PHAssetCollection *)coll;
- (XPhoto *)assetAtIndex:(NSUInteger)index;
- (NSUInteger)indexForIndexPath:(NSIndexPath *)indexPath;
- (NSIndexPath *)indexPathForIndex:(NSUInteger)index;

- (void)loadPhotos;
- (void)saveChecked:(void (^)(void))doneBlock;
- (void)cancelChecked;

@end
